package com.sky.mapper.admin;


import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.pojo.OrderDayAmountVo;
import com.sky.pojo.Orders;
import com.sky.pojo.UserNumberStatistics;
import com.sky.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface AdminOrderMapper {
    // 查询统计图的一句全查 ：
    /*select date (order_time) ,sum(amount) from orders
     where status = 6 and order_time >= '#{begin}'
     and order_time <![CDATA[<]]>'#{end}' group by orderTime;*/

   List<OrderVO> selectOrder(OrdersPageQueryDTO orderDto);
   //牛逼
   @Select("select  count(case when status = 2 then 1 end) waiting4MerchantReceiveOrders,\n" +
           "        count(case when status = 3 then 1 end) waitng4RiderReceiveOrders,\n" +
           "        count(case when status = 4 then 1 end) toBeDeliveryOnProgressOrders,\n" +
           "        count(case when status = 5 then 1 end) toBeArrivedOrders,\n" +
           "        count(case when status = 6 then 1 end) completedOrders,\n" +
           "        count(case when status = 7 then 1 end) canceledOrders\n" +
           "        from orders order by order_time desc ;")
   OrderStatisticsVO selectOrderStatistis();

   OrderVO selectOrderInfo(Long orderId);
  @Update("update orders set status=#{status} where number=#{number}")
   void updateCancellingOrder(Integer status, String number);

    void update(Orders orders);
    @Select("select sum(amount) from orders where order_time like concat(#{day},'%')")
    Double selectSalesVolumesByDay(String day);

   /* List<OrderReportVO> ordersStatistics(LocalDate begin, LocalDate end);*/


    List<OrderDayAmountVo> orderStatistics(LocalDate begin, LocalDate end);

    List<GoodsSalesDTO> dishTop10(LocalDate begin, LocalDate end);
    @Select("select count(*) from user where create_time < concat(#{date},' 00:00:00')")
    int selectUserTotalByDate(String date);

    Map<String, Object> selectEveryDayNewUserTotalByDate( String begin,
                                                          String end,
                                                          List<String> list);
    
    @Select("select count(1) from user where create_time > #{now}")
    Integer getNewUser (LocalDate now);

    DishOverViewVO dishStatusCount();
    SetmealOverViewVO setmealStatusCount();

    OrderDayAmountVo orderExportBaseData(LocalDate begin, LocalDate now);
}
